package org.hhchat.leetcode.tree;

import org.hhchat.leetcode.dataStruct.TreeNode;

/**
 * Created this one by HMH on 2017/10/2.
 */
public class code530_easy {
    class Solution {
        int min = Integer.MAX_VALUE;
        Integer prev = null;
        public int getMinimumDifference(TreeNode root) {
            if (root == null) {
                return 0;
            }
            getMinimumDifference(root.left);
            if (prev != null) {
                min = Math.min(min, Math.abs(root.val - prev));
            }
            prev = root.val;
            getMinimumDifference(root.right);
            return min;
        }
    }

    public static void main(String[] args){

    }
}
